﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FusionDotNet
{
    /// <summary>
    /// Base implementation representing the result of executing a Command.
    /// </summary>
    /// <remarks>
    /// Use this class when the command does not return any additional data.
    /// </remarks>
    public class CommandResult
    {
        /// <summary>
        /// Default Constructor.
        /// </summary>
        public CommandResult()
        {
            ResultExceptions = new List<Exception>(); 
        }

        /// <summary>
        /// Indicates that exceptions occurred whilst processing the Command.
        /// </summary>
        public bool HasExceptions 
        {
            get
            {
                return ResultExceptions.Count() > 0; 
            }
        }

        internal void AddException(System.Exception ex)
        {
            ((List<Exception>)ResultExceptions).Add(ex);
        }

        /// <summary>
        /// IEnumerable containing the exceptions generated by the command.
        /// </summary>
        public IEnumerable<Exception> ResultExceptions { get; private set; }

        /// <summary>
        /// Indicates that the Command failed or succeeded.
        /// </summary>
        public bool Success { get; internal set; }
    }
}
